package Demo8;

class MyThread extends Thread {
    public static int id;

    public MyThread(int id) {
        this.id = id;
    }

    public void run() {
        System.out.println(id);
    }
}
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        //创建20个线程
        for (int i = 0; i < 20; i++) {
            Thread thread = new MyThread(i);
            //分别启动线程
            thread.start();
            //分别等待线程结束
            thread.join();
        }

        System.out.println("ok");


    }
}
